include("jclass.utils");

namespace("jclass.graphics.utils")
({
    RLEParser : jClass({
       public : {
           unpack : function(packed) {
               var i, n, byte, count, unpacked = new jclass.utils.ByteArray();
               while (packed.bytesAvailable) {
                   n = packed.readByte();
                   if (n >= 0) {
                       count = n + 1;
                       for (i = 0; i < count; ++i) {
                           unpacked.writeByte(packed.readByte());
                       }
                   } else {
                       byte = packed.readByte();
                       count = 1 - n;
                       for (i = 0; i < count; ++i) {
                           unpacked.writeByte(byte);
                       }
                   }
               }
               return unpacked;
           }
       }
    }),

    

    GraphicUtils : jClass({
        
    })
});